
local MainScene = class("MainScene", cc.load("mvc").ViewBase)

function MainScene:onCreate()
    local layer = display.newLayer(cc.c4b(128, 128, 128, 255))
    	:addTo(self)
    
    display.newSprite("background.png")
    	:move(display.cx, display.cy)
    	:addTo(layer)

    local starty = 100
    local player = display.newSprite("player.png")
    	:move(display.cx, starty)
    	:addTo(layer)
    local endy = 800
    player:runAction(cc.MoveTo:create(8, cc.p(display.cx, endy)))

    local camera = cc.Camera:createOrthographic(display.width, display.height, 0, 1)
    camera:setCameraFlag(cc.CameraFlag.USER1)
    layer:addChild(camera)

    layer:setCameraMask(cc.CameraFlag.USER1)

    self:scheduleUpdateWithPriorityLua(function(delta)
            camera:setPositionY(player:getPositionY() - starty)
        end, 0)
end

return MainScene
